package cn.com.css.taxInspection.gt3.service.impl;

import cn.com.css.taxInspection.util.DateUtils;
import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.css.taxInspection.gt3.entity.DmGySwjgEntity;
import cn.com.css.taxInspection.gt3.entity.SyJcKhfmxEntity;
import cn.com.css.taxInspection.gt3.mapper.SyJcKhfmxMapper;
import cn.com.css.taxInspection.gt3.service.DmGySwjgService;
import cn.com.css.taxInspection.gt3.service.SyJcKhfmxService;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;

import javax.annotation.Resource;

@Service("syJcKhfmxService")
public class SyJcKhfmxServiceImpl extends ServiceImpl<SyJcKhfmxMapper, SyJcKhfmxEntity> implements SyJcKhfmxService {

    @Resource
    private HttpSessionService httpSessionService;
    @Resource
    private DmGySwjgService dmGySwjgService;

    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public IPage<SyJcKhfmxEntity> infopage1(SyJcKhfmxEntity syJcKhfmxEntity) {
        // String currentUserId = httpSessionService.getCurrentUserId();
        String currentDeptId = httpSessionService.getCurrentDeptId();
        DmGySwjgEntity dmGySwjg = dmGySwjgService.getById(currentDeptId);
        String sjswjgDm = dmGySwjg.getSjswjgDm();
        Page page = new Page(syJcKhfmxEntity.getPage(), syJcKhfmxEntity.getLimit());
        LambdaQueryWrapper<SyJcKhfmxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(SyJcKhfmxEntity::getAjszjgDm, sjswjgDm.substring(0, 9));
        queryWrapper.isNotNull(SyJcKhfmxEntity::getBz);
        queryWrapper.orderByDesc(SyJcKhfmxEntity::getJcajbh);
        // 查询条件示例
        return this.page(page, queryWrapper);
    }

    @Override
    @SuppressWarnings({"rawtypes", "unchecked"})
    public IPage<SyJcKhfmxEntity> infopage(SyJcKhfmxEntity syJcKhfmxEntity) {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        DmGySwjgEntity dmGySwjg = dmGySwjgService.getById(currentDeptId);
        String sjswjgDm = dmGySwjg.getSjswjgDm();
        Page page = new Page(syJcKhfmxEntity.getPage(), syJcKhfmxEntity.getLimit());
        LambdaQueryWrapper<SyJcKhfmxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(SyJcKhfmxEntity::getAjszjgDm, sjswjgDm.substring(0, 9));
        queryWrapper.isNull(SyJcKhfmxEntity::getBz);
		queryWrapper.orderByDesc(SyJcKhfmxEntity::getJcajbh);
        // 查询条件示例
        return this.page(page, queryWrapper);
    }

    @Override
    public void visit(SyJcKhfmxEntity syJcKhfmxEntity) {
        SyJcKhfmxEntity _syJcKhfmxEntity = this.getById(syJcKhfmxEntity.getJcajxxuuid());
        _syJcKhfmxEntity.setBz(syJcKhfmxEntity.getBz());
        _syJcKhfmxEntity.setAjhfrq(DateUtils.getCurrentDate());
        this.updateById(_syJcKhfmxEntity);
    }

}